Do a complete overhaul of the babl API.
authorMartin Nordholts <martinn@src.gnome.org>
Sat, 24 Jan 2009 08:52:04 +0000 (08:52 +0000)
committerMartin Nordholts <martinn@src.gnome.org>
Sat, 24 Jan 2009 08:52:04 +0000 (08:52 +0000)
* babl/babl.h: Instead of including subsystem headers, declare the
functions part of the API directly in the header. The public
types, macros and the version header is still pulled in as
includes but with inclusion guards that prevent them from being
included separately by clients. Notable things removed from the
API is internal class functions and the class instance structs.

(babl_format_has_alpha)
(babl_format_get_bytes_per_pixel)
(babl_format_get_num_of_components)
(babl_format_get_type): New getters to allow the Babl union to
become opaque for clients.

* babl/babl-types.h: New file with public types. Currently only
the opaque Babl union and the linear and planar conversion
function prototypes (which are not used in the API due to the use
of varags but still part of the API for reference) are there. Make
sure it's only included indirectly through babl.h.

* babl/babl-macros.h
* babl/babl-version.h.in: Make sure these are not included
directly, only indirectly through babl.h.

* babl/babl-main.h: Removed, function declarations are in babl.h
now.

* babl/babl-internal.h: Include the headers we now consider
internal, mostly the different class headers.

* babl/babl-class.h: The "named class" function declarations are
now in the public header so move them away from this internal
header.

* babl/babl-image.h
* babl/babl-format.h
* babl/babl-fish.h
* babl/babl-extension.h
* babl/babl-conversion.h
* babl/babl-component.h
* babl/babl-classes.h
* babl/babl-introspect.h
* babl/babl-sampling.h
* babl/babl-model.h
* babl/babl-type.h: Adapt to above changes, move relevant things to babl.h

* babl/base/formats.c
* babl/base/model-gray.c
* babl/base/model-rgb.c
* babl/base/model-ycbcr.c
* babl/base/type-float.c: Explicitly #include "babl-classes.h".

* babl/babl-internal.c: s/babl_name/babl_get_name/

* babl/babl-format.c
(babl_format_has_alpha)
(babl_format_get_bytes_per_pixel)
(babl_format_get_num_of_components)
(babl_format_get_type): Implement these.

* babl/Makefile.am: Don't install the now internal headers and
add, remove and install the other headers according to above
changes.

svn path=/trunk/; revision=390

27 files changed:
ChangeLog
babl/Makefile.am
babl/babl-class.h
babl/babl-classes.h
babl/babl-component.h
babl/babl-conversion.h
babl/babl-extension.h
babl/babl-fish.h
babl/babl-format.c
babl/babl-format.h
babl/babl-image.h
babl/babl-internal.c
babl/babl-internal.h
babl/babl-introspect.h
babl/babl-macros.h
babl/babl-main.h
babl/babl-model.h
babl/babl-sampling.h
babl/babl-type.h
babl/babl-types.h [new file with mode: 0644]
babl/babl-version.h.in
babl/babl.h
babl/base/formats.c
babl/base/model-gray.c
babl/base/model-rgb.c
babl/base/model-ycbcr.c
babl/base/type-float.c

index ac3293bfb8a5d02b8043adc60713d3abd66fe603..126762b9a035914e94c1a627ca034715b9a435d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,70 @@
+2009-01-24  Martin Nordholts  <martinn@svn.gnome.org>
+
+       Do a complete overhaul of the babl API.
+
+       * babl/babl.h: Instead of including subsystem headers, declare the
+       functions part of the API directly in the header. The public
+       types, macros and the version header is still pulled in as
+       includes but with inclusion guards that prevent them from being
+       included separately by clients. Notable things removed from the
+       API is internal class functions and the class instance structs.
+
+       (babl_format_has_alpha)
+       (babl_format_get_bytes_per_pixel)
+       (babl_format_get_num_of_components)
+       (babl_format_get_type): New getters to allow the Babl union to
+       become opaque for clients.
+
+       * babl/babl-types.h: New file with public types. Currently only
+       the opaque Babl union and the linear and planar conversion
+       function prototypes (which are not used in the API due to the use
+       of varags but still part of the API for reference) are there. Make
+       sure it's only included indirectly through babl.h.
+
+       * babl/babl-macros.h
+       * babl/babl-version.h.in: Make sure these are not included
+       directly, only indirectly through babl.h.
+
+       * babl/babl-main.h: Removed, function declarations are in babl.h
+       now.
+
+       * babl/babl-internal.h: Include the headers we now consider
+       internal, mostly the different class headers.
+
+       * babl/babl-class.h: The "named class" function declarations are
+       now in the public header so move them away from this internal
+       header.
+
+       * babl/babl-image.h
+       * babl/babl-format.h
+       * babl/babl-fish.h
+       * babl/babl-extension.h
+       * babl/babl-conversion.h
+       * babl/babl-component.h
+       * babl/babl-classes.h
+       * babl/babl-introspect.h
+       * babl/babl-sampling.h
+       * babl/babl-model.h
+       * babl/babl-type.h: Adapt to above changes, move relevant things to babl.h
+
+       * babl/base/formats.c
+       * babl/base/model-gray.c
+       * babl/base/model-rgb.c
+       * babl/base/model-ycbcr.c
+       * babl/base/type-float.c: Explicitly #include "babl-classes.h".
+
+       * babl/babl-internal.c: s/babl_name/babl_get_name/
+
+       * babl/babl-format.c
+       (babl_format_has_alpha)
+       (babl_format_get_bytes_per_pixel)
+       (babl_format_get_num_of_components)
+       (babl_format_get_type): Implement these.
+
+       * babl/Makefile.am: Don't install the now internal headers and
+       add, remove and install the other headers according to above
+       changes.
+
 2009-01-18  Martin Nordholts  <martinn@svn.gnome.org>
 
        Since babl_foo_from_id() will not be part of the public API we can
index 039e75623912a2cbfa60b45fd86f4bdbdb29f0b4..25932bd8b72cc7ce2be93730424085f96df2f2cb 100644 (file)
@@ -41,8 +41,8 @@ h_sources  =                          \
        babl-internal.h                 \
        babl-introspect.h               \
        babl-macros.h                   \
-       babl-main.h                     \
        babl-memory.h                   \
+       babl-types.h                    \
        babl-util.h                     \
        babl.h                          \
        babl-list.h                     \
@@ -51,22 +51,10 @@ h_sources  =                        \
 
 library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl
 library_include_HEADERS =              \
-       babl.h                          \
-       babl-class.h                    \
-       babl-classes.h                  \
-       babl-component.h                \
-       babl-conversion.h               \
-       babl-extension.h                \
-       babl-fish.h                     \
-       babl-format.h                   \
-       babl-image.h                    \
-       babl-introspect.h               \
        babl-macros.h                   \
-       babl-main.h                     \
-       babl-model.h                    \
-       babl-sampling.h                 \
-       babl-type.h                     \
-       babl-version.h
+       babl-types.h                    \
+       babl-version.h                  \
+       babl.h
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/base
 
index 4b995ad562002d925705c4fa75d1bc719b5df7c0..534c476d0cf011e8aeb5a19c2b82bfb60b5aec91 100644 (file)
 #ifndef _BABL_CLASS_H
 #define _BABL_CLASS_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
+#include "babl.h"
 
-typedef int BablClassType;
 
-typedef union _Babl Babl;
+typedef struct _BablList BablList;
+
+typedef int BablClassType;
 
 typedef int  (*BablEachFunction) (Babl *entry,
                                   void *data);
@@ -42,18 +41,17 @@ void   babl_##klass##_class_destroy  (void);                       \
 void   babl_##klass##_class_for_each (BablEachFunction  each_fun,  \
                                       void             *user_data)
 
-/* creates a class that has a specific name connected to it, that
- * also allows defining a new instance. These classes share common
- * functionality with the non_name classes but have two extra methods,
- * the means to lookup by name, as well as to create new named objects
- * that later can be looked up.
+/* If a class is declared as a "named class" it means it is a class
+ * that has a specific name connected to it, that also allows defining
+ * a new instance. These classes share common functionality with the
+ * non_name classes but have two extra methods, the means to lookup by
+ * name, as well as to create new named objects that later can be
+ * looked up. These methods are babl_klass() babl_klass_new() but they
+ * are declared outside of this macro.
  */
-#define BABL_NAMED_CLASS_DECLARE(klass)                        \
-                                                               \
-BABL_CLASS_DECLARE (klass);                                    \
-Babl * babl_##klass             (const char       *name);      \
-Babl * babl_##klass##_new       (void             *first_arg,  \
-                                  ...) BABL_ARG_NULL_TERMINATED
+#define BABL_NAMED_CLASS_DECLARE(klass) \
+BABL_CLASS_DECLARE (klass)
+
 
 /* common header for any item inserted into database, the actual
  * implementation of babl-instance is in babl-internal
index 84b694cdf5d9f3441dcc2a01c581e85a0bedcfe9..eeaa262be44633232dc19c6817ac5617d4b3a0c3 100644 (file)
 #ifndef _BABL_CLASSES_H
 #define _BABL_CLASSES_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
+#include "babl-class.h"
 
 /* magic number used at the start of all babl objects, used to do
  * differentiation in polymorphic functions. (as well as manual type
index e7f7852f84960c3c3a8a09ad0987e85e35c98852..df9d7199342deda699a012a0348badacdf344b6c 100644 (file)
 #ifndef _BABL_COMPONENT_H
 #define _BABL_COMPONENT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
 
 /****************************************************************/
 /* BablComponent */
 BABL_NAMED_CLASS_DECLARE (component);
-/*
- * Babl * babl_component_new (const char *name,
- *                            NULL);
- */
 
 
 typedef struct
index edfc8d2e30dbf9afb8cd8b6d762e29215ef1b55d..d231b6484b060bd4cf3dc3786c58d63709148e4d 100644 (file)
 #ifndef _BABL_CONVERSION_H
 #define _BABL_CONVERSION_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablConversion */
 BABL_NAMED_CLASS_DECLARE (conversion);
-/*
- * Babl * babl_conversion_new (<BablFormat *source, BablFormat *destination|
- *                              BablModel  *source, BablModel  *destination|
- *                              BablType   *source, BablType   *destination>,
- *                             <"linear"|"planar">, BablConversionFunc conv_func,
- *                              NULL);
- */
+
+Babl * babl_conversion (const char *name);
 
 
-/* Type and Format */
-typedef long (*BablFuncLinear)    (char  *src,
-                                   char  *dst,
-                                   long   n);
 
 /* Signature of functions registered for reference type
  * conversions,
@@ -49,14 +34,6 @@ typedef long (*BablFuncPlane)     (char  *src,
                                    int    dst_pitch,
                                    long   n);
 
-/* TypePlanar,ModelPlanar and FormatPlanar */
-typedef long (*BablFuncPlanar)    (int    src_bands,
-                                   char  *src[],
-                                   int    src_pitch[],
-                                   int    dst_bands,
-                                   char  *dst[],
-                                   int    dst_pitch[],
-                                   long   n);
 
 typedef struct
 BablConversion {
index 9652e245d1d685d7dca58ce5ec2ec53994436d39..cd7f83134c1d6c4509c6129c834ef66f5da3bab9 100644 (file)
@@ -19,9 +19,6 @@
 #ifndef _BABL_EXTENSION_H
 #define _BABL_EXTENSION_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
 
 /****************************************************************/
 /* BablExtension */
@@ -30,6 +27,8 @@ BABL_NAMED_CLASS_DECLARE (extension);
  * BablExtension objects are only used internally in babl.
  */
 
+Babl * babl_extension (const char *name);
+
 
 typedef struct
 {
index b04a689f18c555f3238e2b5ec0438feb4e7d45bc..159232960659a129ba4f89902f7d0ce0e62f153c 100644 (file)
 #ifndef _BABL_FISH_H
 #define _BABL_FISH_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h 
-#endif
 
 /****************************************************************/
 /* BablFish */
 BABL_CLASS_DECLARE (fish);
-/*  Create a babl fish capable of converting from source_format to
- *  destination_format, source and destination can be
- *  either strings with the names of the formats or BablFormat objects.
- */
-Babl * babl_fish       (const void *source_format,
-                        const void *destination_format);
-
-/** Process n pixels from source to destination using babl_fish,
- *  returns number of pixels converted. 
- */
-long   babl_process    (Babl *babl_fish,
-                        void *source,
-                        void *destination,
-                        long  n);
 
 /* BablFish, common base class for various fishes.
  */
index f72143aaa4b5dd6784a1d5106dab4fe15e947a4b..45dfa0512c1fc48b70bad11f545f1f71aee1aa33 100644 (file)
@@ -328,6 +328,59 @@ babl_formats_count (void)
   return babl_db_count (db);
 }
 
+int
+babl_format_has_alpha (const Babl *format)
+{
+  int i;
+  int has_alpha = 0;
+
+  for (i = 0; i < babl_format_get_num_of_components (format); i++)
+    {
+      if (format->format.component[i]->alpha)
+        {
+          has_alpha = 1;
+          break;
+        }
+    }
+
+  return has_alpha;
+}
+
+int
+babl_format_get_bytes_per_pixel (const Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.bytes_per_pixel;
+    }
+
+  return 0;
+}
+
+int
+babl_format_get_num_of_components (const Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.components;
+    }
+
+  return 0;
+}
+
+Babl *
+babl_format_get_type (const Babl *format,
+                      int         component_index)
+{
+  if (format->class_type == BABL_FORMAT &&
+      component_index >= 0 &&
+      component_index < format->format.components)
+    {
+      return (Babl *)format->format.type[component_index];
+    }
+
+  return NULL;
+}
 
 Babl *
 babl_format_with_model_as_type (Babl *model,
index 1e1de1f4aebb3e4c5d8e58402090c1e9cc3be79a..f130bcdd8a514074cc1e724784b9064a84eecd25 100644 (file)
 #ifndef _BABL_FORMAT_H
 #define _BABL_FORMAT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablFormat */
 BABL_NAMED_CLASS_DECLARE (format);
-/*
- * Babl * babl_format_new (["name", const char *name,]
- *                          BablModel          *model,
- *                         [BablType           *type,]
- *                         [BablSampling,      *sampling,]
- *                          BablComponent      *component1,
- *                        [[BablType           *type,]
- *                         [BablSampling       *sampling,]
- *                          BablComponent      *componentN,
- *                        ...]
- *                          ["planar",]
- *                          NULL);
- *
- * Provided BablType and|or BablSampling is valid for the following
- * components as well. If no name is provided a (long) descriptive
- * name is used.
- */
-
 
 typedef struct
 {
index ca2787a77e69c63012157799357fff8ddd4845ac..2b7a2a8d90c43f9eb6a751a65e0b71bfc04908eb 100644 (file)
@@ -19,9 +19,6 @@
 #ifndef _BABL_IMAGE_H
 #define _BABL_IMAGE_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
 
 /****************************************************************/
 /* BablImage */
index 8de4ce59c36bd2459b4b4c1ee1057c5bedacd731..8fd7fba085e04c32f31e81d1b8b48c93d0fab8e4 100644 (file)
@@ -132,7 +132,7 @@ babl_internal_destroy (void)
 
 
 const char *
-babl_name (const Babl *babl)
+babl_get_name (const Babl *babl)
 {
   babl_assert (BABL_IS_BABL (babl));
   return babl->instance.name;
index 6024d87663ad46819a6b6b626a9081772463df49..7baf910ade9a7c3d110feb29343b41203bce2b3c 100644 (file)
@@ -38,6 +38,9 @@
 
 #include "config.h"
 
+#include "babl-class.h"
+#include "babl-classes.h"
+#include "babl-introspect.h"
 #include "babl-list.h"
 #include "babl-hash-table.h"
 #include "babl-db.h"
index 6b6d95db1244eb4736f22493e112788a0e48bb26..6e32a2a6a3d5f238477a5dcf06412819915dec84 100644 (file)
 #ifndef _BABL_INTROSPECT_H
 #define _BABL_INTROSPECT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-
-/**
- * babl_name:
- *
- * Return a string decsribing a BablInstance, might work better than
- * babl->instance.name when a good human readable name is desired.
- *
- * Returns: a name describing the instance.
- */
-const char * babl_name       (const Babl *babl);
 
 void         babl_introspect (Babl       *babl); /* introspect a given BablObject     */
 
index 7eae0842732937f6e5c7360ebcf2909a4167ce38..8de6864930be91268c204c5a5bb8a569fd7c0975 100644 (file)
 #ifndef _BABL_MACROS_H
 #define _BABL_MACROS_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
 #endif
 
+
 #if     __GNUC__ >= 4
 #define BABL_ARG_NULL_TERMINATED __attribute__((__sentinel__))
 #else
index 8cfafa5f27eb2962e71321fb0e0735c5987a5411..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,46 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005-2008, Øyvind Kolås and others.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _BABL_MAIN_H
-#define _BABL_MAIN_H
-
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/**
- * Initialize the babl library
- */
-void   babl_init       (void);
-
-/**
- * Deinitialize the babl library (frees any resources used, if the
- * number of calls to babl_exit() is is equal to the number of calls
- * to babl_init()
- */
-void   babl_exit       (void);
-
-
-#ifndef BABL_DISABLE_DEPRECATED
-
-#define babl_destroy babl_exit
-
-#endif /* BABL_DISABLE_DEPRECATED */
-
-
-#endif
index 7b8a54c36df8832ade423f74c083d9f957140356..617c91c8fb57cdda4ee446be6be64eb58d7ef95f 100644 (file)
 #ifndef _BABL_MODEL_H
 #define _BABL_MODEL_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablModel */
 BABL_NAMED_CLASS_DECLARE (model);
-/*
- * Babl * babl_model_new (["name", const char *name,]
- *                        BablComponent *component1,
- *                       [BablComponent *componentN, ...]
- *                        NULL);
- *
- * If no name is provided a name is generated by concatenating the
- * name of all the involved components.
- *
- */
-
 
 typedef struct
 {
index 319d80d3cc4a25132f1d608954aca2f37e731b05..869e3de86d08a5dbd0e4a9a4a6bfaeefbd3f2d45 100644 (file)
 #ifndef _BABL_SAMPLING_H
 #define _BABL_SAMPLING_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h 
-#endif
-
-/****************************************************************/
-/* BablSampling */
 BABL_CLASS_DECLARE (sampling);
-/**/
-Babl * babl_sampling       (int horizontal,
-                            int vertical);
+
 typedef struct
 {
   BablInstance     instance;
index 581317c989c9f6ebef03c86a8117b950edbee31b..10e40409aefabe27d207e799de74381c572d1b09 100644 (file)
 #ifndef _BABL_TYPE_H
 #define _BABL_TYPE_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablType */
 BABL_NAMED_CLASS_DECLARE (type);
-/*
- * A data type that babl can have in it's buffers, requires
- * conversions to and from "double" to be registered before
- * passing sanity.
- *
- * Babl * babl_type_new (  const char *name,
- *                         "bits",     int bits,
- *                         ["min_val", double min_val,]
- *                         ["max_val", double max_val,]
- *                         NULL);
- */
-
 
 typedef struct
 {
diff --git a/babl/babl-types.h b/babl/babl-types.h
new file mode 100644 (file)
index 0000000..d1deae7
--- /dev/null
@@ -0,0 +1,49 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005-2008, Øyvind Kolås and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BABL_TYPES_H
+#define _BABL_TYPES_H
+
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
+#endif
+
+
+/**
+ * The babl API is based around polymorphism and almost everything is
+ * a Babl object.
+ */
+typedef union _Babl Babl;
+
+/* Conversion function between linear data of a either a data types or
+ * color formats.
+ */
+typedef long (*BablFuncLinear)    (char  *src,
+                                   char  *dst,
+                                   long   n);
+
+/* TypePlanar,ModelPlanar and FormatPlanar */
+typedef long (*BablFuncPlanar)    (int    src_bands,
+                                   char  *src[],
+                                   int    src_pitch[],
+                                   int    dst_bands,
+                                   char  *dst[],
+                                   int    dst_pitch[],
+                                   long   n);
+
+#endif
index 40d39306e632695af985e7016e8587aa62583746..97890994a21101b71a7f6c4622b9e57d77223a04 100644 (file)
 #ifndef _BABL_VERSION_H
 #define _BABL_VERSION_H
 
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
+#endif
+
+
 /***
  * babl version information
  *
index f953c1cb49d266eb180cba787d289b34d1eafa26..bd538393c70a5e872798f2858859f3e209ac4785 100644 (file)
  * <http://www.gnu.org/licenses/>.
  */
 
-/* NOTE! the babl API is polymorphic, it is probably easier to learn
- * it's usage by studying examples than this header file. The public
- * functions are attempted explained anyways.
- */
-
 #ifndef _BABL_H
 #define _BABL_H
 
-#ifdef _BABL_INTERNAL_H
-#error babl.h included after babl-internal.h
-#endif
+#define BABL_INSIDE_BABL_H
+#include "babl-version.h"
+#include "babl-macros.h"
+#include "babl-types.h"
+#undef BABL_INSIDE_BABL_H
 
 
-typedef struct _BablList BablList;
+/**
+ * Initializes the babl library.
+ */
+void         babl_init      (void);
 
-#include "babl-macros.h"
-#include "babl-main.h"
-#include "babl-class.h"
-#include "babl-introspect.h"
-#include "babl-version.h"
-#include "babl-classes.h"
+/**
+ * Deinitializes the babl library and frees any resources used when
+ * matched with the number of calls to babl_init().
+ */
+void         babl_exit      (void);
+
+/**
+ * Returns the babl object representing the data type given by @name
+ * such as for example "u8", "u16" or "float".
+ */
+Babl *       babl_type      (const char *name);
+
+/**
+ * Returns the babl object representing the @horizontal and @vertical
+ * sampling such as for example 2, 2 for the chroma components in
+ * YCbCr.
+ */
+Babl *       babl_sampling  (int horizontal,
+                             int vertical);
+
+/**
+ * Returns the babl object representing the color component given by
+ * @name such as for example "R", "cyan" or "CIE L".
+ */
+Babl *       babl_component (const char *name);
+
+/**
+ * Returns the babl object representing the color model given by @name
+ * such as for example "RGB", "CMYK" or "CIE Lab".
+ */
+Babl *       babl_model     (const char *name);
+
+/**
+ * Returns the babl object representing the color format given by
+ * @name such as for example "RGB u8", "CMYK float" or "CIE Lab u16".
+ */
+Babl *       babl_format    (const char *name);
+
+/*  Create a babl fish capable of converting from source_format to
+ *  destination_format, source and destination can be either strings
+ *  with the names of the formats or Babl-format objects.
+ */
+Babl *       babl_fish      (const void *source_format,
+                             const void *destination_format);
+
+/** Process n pixels from source to destination using babl_fish,
+ *  returns number of pixels converted.
+ */
+long         babl_process   (Babl *babl_fish,
+                             void *source,
+                             void *destination,
+                             long  n);
+
+
+/**
+ * Returns a string decsribing a Babl object.
+ */
+const char * babl_get_name                     (const Babl *babl);
+
+/**
+ * Returns whether the @format has an alpha channel.
+ */
+int          babl_format_has_alpha             (const Babl *format);
+
+/**
+ * Returns the bytes per pixel for a babl color format.
+ */
+int          babl_format_get_bytes_per_pixel   (const Babl *format);
+
+/**
+ * Returns the number of components for the given @format.
+ */
+int          babl_format_get_num_of_components (const Babl *format);
+
+/**
+ * Returns the type in the given @format for the given
+ * @component_index.
+ */
+Babl *       babl_format_get_type              (const Babl *format,
+                                                int         component_index);
+
+
+/**
+ * Defines a new data type in babl. A data type that babl can have in
+ * its buffers requires conversions to and from "double" to be
+ * registered before passing sanity.
+ *
+ *     babl_type_new       (const char *name,
+ *                          "bits",     int bits,
+ *                          ["min_val", double min_val,]
+ *                          ["max_val", double max_val,]
+ *                          NULL);
+ */
+Babl * babl_type_new       (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color component with babl.
+ *
+ *     babl_component_new  (const char *name,
+ *                          NULL);
+ */
+Babl * babl_component_new  (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color model in babl. If no name is provided a name is
+ * generated by concatenating the name of all the involved components.
+ *
+ *     babl_model_new      (["name", const char *name,]
+ *                          BablComponent *component1,
+ *                          [BablComponent *componentN, ...]
+ *                          NULL);
+ */
+Babl * babl_model_new      (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color format in babl. Provided BablType and|or
+ * BablSampling is valid for the following components as well. If no
+ * name is provided a (long) descriptive name is used.
+ *
+ *     babl_format_new     (["name", const char *name,]
+ *                          BablModel          *model,
+ *                          [BablType           *type,]
+ *                          [BablSampling,      *sampling,]
+ *                          BablComponent      *component1,
+ *                          [[BablType           *type,]
+ *                           [BablSampling       *sampling,]
+ *                           BablComponent      *componentN,
+ *                           ...]
+ *                          ["planar",]
+ *                          NULL);
+ */
+Babl * babl_format_new     (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new conversion between either two formats, two models or
+ * two types in babl.
+ *
+ *     babl_conversion_new (<BablFormat *source, BablFormat *destination|
+ *                          BablModel  *source, BablModel  *destination|
+ *                          BablType   *source, BablType   *destination>,
+ *                          <"linear"|"planar">, <BablFuncLinear | BablFuncPlanar> conv_func,
+ *                          NULL);
+ */
+Babl * babl_conversion_new (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+
+/*
+ * Backwards compatibility stuff
+ *
+ * NOTE: will most likely be removed in the first stable release!
+ */
+#ifndef BABL_DISABLE_DEPRECATED
+#define babl_destroy babl_exit
+#endif
 
 
 #endif
index a72d9f35d2b0eeac021900cdab0a08bcd45a70ea..212b86a44bc79788d3158c2882e2f864806b0f01 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdlib.h>
 
+#include "babl-classes.h"
 #include "babl.h"
 #include "babl-ids.h"
 #include "babl-base.h"
index 1684879f1c606eaea55bd3e40da2f0f88e08eb90..f46eb59eb291580dcbf9c43a5375986cb9d06cab 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdlib.h>
 
+#include "babl-classes.h"
 #include "babl.h"
 #include "babl-ids.h"
 #include "util.h"
index 4edbea778b372735a46f73be4fbe2b859d8f49ee..da772c79df8e40f5c68828090f827729ded997d0 100644 (file)
@@ -20,6 +20,7 @@
 #include <math.h>
 
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "util.h"
 #include "babl-base.h"
index ba3d706ad948ca88c6a9a02400fab09c1477e10d..dc766ece65b15788d9a37b15c4f2c5a7420ab554 100644 (file)
@@ -19,7 +19,9 @@
 #include <string.h>
 #include <math.h>
 #include <assert.h>
+
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "babl-base.h"
 
index c358b1683c61fc0d99205f087996659a6ff38ea2..b8f7620d132b0c93f807635d605569b422f5575a 100644 (file)
@@ -20,6 +20,7 @@
 #include <assert.h>
 
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "babl-base.h"